function commonFunction() {
    //短标题
    jQuery("#S_titleControl").click(function(){jQuery("#S_title").toggle();});
    //栏目、区块ID
    jQuery(".idValue",jQuery(".showId").parent()).parent().hide();
    jQuery(".showId").bind("click",function(){
        jQuery(".idValue",jQuery(this).parent()).parent().toggle();
    });
}

function columnAttributeFieldSet(){			//设置填写栏目、区块ID后，获取名称处理方法
    jQuery("#mainColumnId").focusout(function(){
        var columnId= jQuery("#mainColumnId").val();
        columnId= columnId.split(/[,，]/gi);
        $.ajax({
            url: '/admin/site/column/search.do?select=1&ids='+columnId[0],
            dataType: 'json',
            success: function(data) {
                if(data[columnId[0]]!== ""){
                    jQuery("#mainColumnId").val(columnId[0]);
                    jQuery("#mainColumn").val(data[columnId[0]]);
                }
                else{
                    jQuery("#mainColumnId").val("");
                    jQuery("#mainColumn").val("");
                }
            }
        });
    });
    jQuery("#relateColumnIds").focusout(function(){
        var columnIds= jQuery("#relateColumnIds").val();
        jQuery.ajax({
            url: '/admin/site/column/search.do?select=1&ids='+columnIds,
            dataType: 'json',
            success: function(data) {
                columnIds= columnIds.split(/[,，]/gi);
                var columns= "";
                var newColumnIds= "";
                for(var i=0; i< columnIds.length; i++){
                    if(data[columnIds[i]]!== "" && data[columnIds[i]]!==undefined){
                        columns= columns+ data[columnIds[i]]+ "，";
                        newColumnIds= newColumnIds+ columnIds[i]+ ",";
                    }
                }
                columns= columns.slice(0,-1);
                newColumnIds= newColumnIds.slice(0,-1);
                jQuery("#relateColumnIds").val(newColumnIds);
                jQuery("#relateColumns").val(columns);
            }
        });
    });
    jQuery("#regionIds").focusout(function(){
        var regionIds= jQuery("#regionIds").val();
        jQuery.ajax({
            url: '/admin/site/region/search.do?select=1&ids='+regionIds,
            dataType: 'json',
            success: function(data) {
                regionIds= regionIds.split(/[,，]/gi);
                var regions= "";
                var newregionIds= "";
                for(var i=0; i< regionIds.length; i++){
                    if(data[regionIds[i]]!== "" && data[regionIds[i]]!==undefined){
                        regions= regions+ data[regionIds[i]]+ "，";
                        newregionIds= newregionIds+ regionIds[i]+ ",";
                    }
                }
                regions= regions.slice(0,-1);
                newregionIds= newregionIds.slice(0,-1);
                jQuery("#regionIds").val(newregionIds);
                jQuery("#regions").val(regions);
            }
        });
    });
}

function submitForm(){
    // // 检查是否修改过图片
    // var editorContent = editor.getData();
    // var newImgs = findImgSrc(editorContent);
    // if (checkChanged(newImgs, imgs)) {
    //     $("#isImgChanged").val(1);
    // }
    //
    // var newThumb = [];
    // $("input:checkbox[name=thumbPicUrl]:checked").each(function(i){
    //     newThumb.push($(this).val());
    // });
    // if (checkChanged(newThumb, thumb)) {
    //     $("#isImgChanged").val(1);
    // }

    document.mainform.submit();
}

function callbackMainColumn(jsonData){		//选择主栏目后返回方法，设置ID和名称
    var result=  jQuery.parseJSON(jsonData);
    jQuery("#mainColumnId").val(result[0].id);
    jQuery("#mainColumn").val(result[0].name);
}

function callbackRelateColumn(jsonData){		//选择从栏目后返回方法，设置ID和名称
    var idString,nameString;
    var result= jQuery.parseJSON(jsonData);
    var sourceID= jQuery("#relateColumnIds").val();
    var sourceName= jQuery("#relateColumns").val();
    idString= result[0].id;
    nameString= result[0].name;
    for(var i=1; i< result.length; i++){
        idString=idString+','+result[i].id;
        nameString=nameString+'，'+result[i].name;
    }
    if(sourceID != ""){
        idString= sourceID +',' +idString;
    }
    if(sourceName != ""){
        nameString= sourceName +'，'+nameString;
    }
    jQuery("#relateColumnIds").val(idString);
    jQuery("#relateColumns").val(nameString);
}

function callbackRegion(jsonData){		//选择区块后返回方法，设置ID和名称
    var idString,nameString;
    var result= jQuery.parseJSON(jsonData);
    var sourceID= jQuery("#regionIds").val();
    var sourceName= jQuery("#regions").val();
    idString= result[0].id;
    nameString= result[0].name;
    for(var i=1; i< result.length; i++){
        idString=idString+','+result[i].id;
        nameString=nameString+'，'+result[i].name;
    }
    if(sourceID != ""){
        idString= sourceID +',' +idString;
    }
    if(sourceName != ""){
        nameString= sourceName +'，'+nameString;
    }
    jQuery("#regionIds").val(idString);
    jQuery("#regions").val(nameString);
}